﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;

namespace Atomic.Common
{
    public static class JsonExtend
    {
        /// <summary>
        /// 转换为EasyUI识别的Json格式
        /// </summary>
        /// <param name="obj">当前页记录</param>
        /// <param name="total">用于计算页数的记录总数</param>
        /// <returns></returns>
        public static string ToEasyUIJson(this object obj, int total)
        {
            string json = JsonConvert.SerializeObject(obj);
            return new StringBuilder("{\"total\":")
                .Append(total)
                .Append(",\"rows\":")
                .Append(json)
                .Append("}")
                .ToString();
        }
    }
}
